package com.lz.basic;

public class ArraySort {

	/**
	 * 冒泡排序
	 */
	public static void main(String[] args) {
		int arr[] = { 12, 11, 16, 21, 29, 27, 25, 23 };
		System.out.println("排序前");
		for (int i = 0; i < arr.length; i++) {
			
			System.out.print(arr[i]+"\t");
		}
		System.out.println();
		for (int i = 0; i < arr.length - 1; i++) {
			for (int j = 0; j < arr.length - 1; j++) {
				if (arr[j] < arr[j + 1]) {
					int temp = arr[j];
					arr[j] = arr[j + 1];
					arr[j + 1] = temp;

				}

			}
			System.out.println("第" + (i + 1) + "次排序");
			for (int k = 0; k < arr.length; k++) {

				System.out.print(arr[k] + "\t");
			}

			System.out.println();
		}
		System.out.println("最终排序");
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i] + "\t");
		}

	}

}
